/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.swt.mto.thithu.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.util.PortalUtil;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import com.swt.mto.thithu.model.QuizCategory;
import com.swt.mto.thithu.model.QuizCategoryModel;

import java.io.Serializable;

import java.sql.Types;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * The base model implementation for the QuizCategory service. Represents a row in the &quot;mto_thithu_QuizCategory&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link com.swt.mto.thithu.model.QuizCategoryModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link QuizCategoryImpl}.
 * </p>
 *
 * @author tuan.nguyen
 * @see QuizCategoryImpl
 * @see com.swt.mto.thithu.model.QuizCategory
 * @see com.swt.mto.thithu.model.QuizCategoryModel
 * @generated
 */
public class QuizCategoryModelImpl extends BaseModelImpl<QuizCategory>
	implements QuizCategoryModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a quiz category model instance should use the {@link com.swt.mto.thithu.model.QuizCategory} interface instead.
	 */
	public static final String TABLE_NAME = "mto_thithu_QuizCategory";
	public static final Object[][] TABLE_COLUMNS = {
			{ "quizCategoryId", Types.BIGINT },
			{ "parentId", Types.BIGINT },
			{ "createUserId", Types.BIGINT },
			{ "modifyUserId", Types.BIGINT },
			{ "title", Types.VARCHAR },
			{ "description", Types.VARCHAR },
			{ "createDate", Types.TIMESTAMP },
			{ "modifydate", Types.TIMESTAMP }
		};
	public static final String TABLE_SQL_CREATE = "create table mto_thithu_QuizCategory (quizCategoryId LONG not null primary key,parentId LONG,createUserId LONG,modifyUserId LONG,title VARCHAR(75) null,description VARCHAR(75) null,createDate DATE null,modifydate DATE null)";
	public static final String TABLE_SQL_DROP = "drop table mto_thithu_QuizCategory";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.com.swt.mto.thithu.model.QuizCategory"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.com.swt.mto.thithu.model.QuizCategory"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.column.bitmask.enabled.com.swt.mto.thithu.model.QuizCategory"),
			true);
	public static long PARENTID_COLUMN_BITMASK = 1L;
	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.com.swt.mto.thithu.model.QuizCategory"));

	public QuizCategoryModelImpl() {
	}

	public long getPrimaryKey() {
		return _quizCategoryId;
	}

	public void setPrimaryKey(long primaryKey) {
		setQuizCategoryId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_quizCategoryId);
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	public Class<?> getModelClass() {
		return QuizCategory.class;
	}

	public String getModelClassName() {
		return QuizCategory.class.getName();
	}

	@Override
	public Map<String, Object> getModelAttributes() {
		Map<String, Object> attributes = new HashMap<String, Object>();

		attributes.put("quizCategoryId", getQuizCategoryId());
		attributes.put("parentId", getParentId());
		attributes.put("createUserId", getCreateUserId());
		attributes.put("modifyUserId", getModifyUserId());
		attributes.put("title", getTitle());
		attributes.put("description", getDescription());
		attributes.put("createDate", getCreateDate());
		attributes.put("modifydate", getModifydate());

		return attributes;
	}

	@Override
	public void setModelAttributes(Map<String, Object> attributes) {
		Long quizCategoryId = (Long)attributes.get("quizCategoryId");

		if (quizCategoryId != null) {
			setQuizCategoryId(quizCategoryId);
		}

		Long parentId = (Long)attributes.get("parentId");

		if (parentId != null) {
			setParentId(parentId);
		}

		Long createUserId = (Long)attributes.get("createUserId");

		if (createUserId != null) {
			setCreateUserId(createUserId);
		}

		Long modifyUserId = (Long)attributes.get("modifyUserId");

		if (modifyUserId != null) {
			setModifyUserId(modifyUserId);
		}

		String title = (String)attributes.get("title");

		if (title != null) {
			setTitle(title);
		}

		String description = (String)attributes.get("description");

		if (description != null) {
			setDescription(description);
		}

		Date createDate = (Date)attributes.get("createDate");

		if (createDate != null) {
			setCreateDate(createDate);
		}

		Date modifydate = (Date)attributes.get("modifydate");

		if (modifydate != null) {
			setModifydate(modifydate);
		}
	}

	public long getQuizCategoryId() {
		return _quizCategoryId;
	}

	public void setQuizCategoryId(long quizCategoryId) {
		_quizCategoryId = quizCategoryId;
	}

	public long getParentId() {
		return _parentId;
	}

	public void setParentId(long parentId) {
		_columnBitmask |= PARENTID_COLUMN_BITMASK;

		if (!_setOriginalParentId) {
			_setOriginalParentId = true;

			_originalParentId = _parentId;
		}

		_parentId = parentId;
	}

	public long getOriginalParentId() {
		return _originalParentId;
	}

	public long getCreateUserId() {
		return _createUserId;
	}

	public void setCreateUserId(long createUserId) {
		_createUserId = createUserId;
	}

	public String getCreateUserUuid() throws SystemException {
		return PortalUtil.getUserValue(getCreateUserId(), "uuid",
			_createUserUuid);
	}

	public void setCreateUserUuid(String createUserUuid) {
		_createUserUuid = createUserUuid;
	}

	public long getModifyUserId() {
		return _modifyUserId;
	}

	public void setModifyUserId(long modifyUserId) {
		_modifyUserId = modifyUserId;
	}

	public String getModifyUserUuid() throws SystemException {
		return PortalUtil.getUserValue(getModifyUserId(), "uuid",
			_modifyUserUuid);
	}

	public void setModifyUserUuid(String modifyUserUuid) {
		_modifyUserUuid = modifyUserUuid;
	}

	public String getTitle() {
		if (_title == null) {
			return StringPool.BLANK;
		}
		else {
			return _title;
		}
	}

	public void setTitle(String title) {
		_title = title;
	}

	public String getDescription() {
		if (_description == null) {
			return StringPool.BLANK;
		}
		else {
			return _description;
		}
	}

	public void setDescription(String description) {
		_description = description;
	}

	public Date getCreateDate() {
		return _createDate;
	}

	public void setCreateDate(Date createDate) {
		_createDate = createDate;
	}

	public Date getModifydate() {
		return _modifydate;
	}

	public void setModifydate(Date modifydate) {
		_modifydate = modifydate;
	}

	public long getColumnBitmask() {
		return _columnBitmask;
	}

	@Override
	public ExpandoBridge getExpandoBridge() {
		return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
			QuizCategory.class.getName(), getPrimaryKey());
	}

	@Override
	public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
		ExpandoBridge expandoBridge = getExpandoBridge();

		expandoBridge.setAttributes(serviceContext);
	}

	@Override
	public QuizCategory toEscapedModel() {
		if (_escapedModelProxy == null) {
			_escapedModelProxy = (QuizCategory)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelProxyInterfaces,
					new AutoEscapeBeanHandler(this));
		}

		return _escapedModelProxy;
	}

	@Override
	public Object clone() {
		QuizCategoryImpl quizCategoryImpl = new QuizCategoryImpl();

		quizCategoryImpl.setQuizCategoryId(getQuizCategoryId());
		quizCategoryImpl.setParentId(getParentId());
		quizCategoryImpl.setCreateUserId(getCreateUserId());
		quizCategoryImpl.setModifyUserId(getModifyUserId());
		quizCategoryImpl.setTitle(getTitle());
		quizCategoryImpl.setDescription(getDescription());
		quizCategoryImpl.setCreateDate(getCreateDate());
		quizCategoryImpl.setModifydate(getModifydate());

		quizCategoryImpl.resetOriginalValues();

		return quizCategoryImpl;
	}

	public int compareTo(QuizCategory quizCategory) {
		long primaryKey = quizCategory.getPrimaryKey();

		if (getPrimaryKey() < primaryKey) {
			return -1;
		}
		else if (getPrimaryKey() > primaryKey) {
			return 1;
		}
		else {
			return 0;
		}
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		QuizCategory quizCategory = null;

		try {
			quizCategory = (QuizCategory)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long primaryKey = quizCategory.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public void resetOriginalValues() {
		QuizCategoryModelImpl quizCategoryModelImpl = this;

		quizCategoryModelImpl._originalParentId = quizCategoryModelImpl._parentId;

		quizCategoryModelImpl._setOriginalParentId = false;

		quizCategoryModelImpl._columnBitmask = 0;
	}

	@Override
	public CacheModel<QuizCategory> toCacheModel() {
		QuizCategoryCacheModel quizCategoryCacheModel = new QuizCategoryCacheModel();

		quizCategoryCacheModel.quizCategoryId = getQuizCategoryId();

		quizCategoryCacheModel.parentId = getParentId();

		quizCategoryCacheModel.createUserId = getCreateUserId();

		quizCategoryCacheModel.modifyUserId = getModifyUserId();

		quizCategoryCacheModel.title = getTitle();

		String title = quizCategoryCacheModel.title;

		if ((title != null) && (title.length() == 0)) {
			quizCategoryCacheModel.title = null;
		}

		quizCategoryCacheModel.description = getDescription();

		String description = quizCategoryCacheModel.description;

		if ((description != null) && (description.length() == 0)) {
			quizCategoryCacheModel.description = null;
		}

		Date createDate = getCreateDate();

		if (createDate != null) {
			quizCategoryCacheModel.createDate = createDate.getTime();
		}
		else {
			quizCategoryCacheModel.createDate = Long.MIN_VALUE;
		}

		Date modifydate = getModifydate();

		if (modifydate != null) {
			quizCategoryCacheModel.modifydate = modifydate.getTime();
		}
		else {
			quizCategoryCacheModel.modifydate = Long.MIN_VALUE;
		}

		return quizCategoryCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(17);

		sb.append("{quizCategoryId=");
		sb.append(getQuizCategoryId());
		sb.append(", parentId=");
		sb.append(getParentId());
		sb.append(", createUserId=");
		sb.append(getCreateUserId());
		sb.append(", modifyUserId=");
		sb.append(getModifyUserId());
		sb.append(", title=");
		sb.append(getTitle());
		sb.append(", description=");
		sb.append(getDescription());
		sb.append(", createDate=");
		sb.append(getCreateDate());
		sb.append(", modifydate=");
		sb.append(getModifydate());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(28);

		sb.append("<model><model-name>");
		sb.append("com.swt.mto.thithu.model.QuizCategory");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>quizCategoryId</column-name><column-value><![CDATA[");
		sb.append(getQuizCategoryId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>parentId</column-name><column-value><![CDATA[");
		sb.append(getParentId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>createUserId</column-name><column-value><![CDATA[");
		sb.append(getCreateUserId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>modifyUserId</column-name><column-value><![CDATA[");
		sb.append(getModifyUserId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>title</column-name><column-value><![CDATA[");
		sb.append(getTitle());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>description</column-name><column-value><![CDATA[");
		sb.append(getDescription());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>createDate</column-name><column-value><![CDATA[");
		sb.append(getCreateDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>modifydate</column-name><column-value><![CDATA[");
		sb.append(getModifydate());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = QuizCategory.class.getClassLoader();
	private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
			QuizCategory.class
		};
	private long _quizCategoryId;
	private long _parentId;
	private long _originalParentId;
	private boolean _setOriginalParentId;
	private long _createUserId;
	private String _createUserUuid;
	private long _modifyUserId;
	private String _modifyUserUuid;
	private String _title;
	private String _description;
	private Date _createDate;
	private Date _modifydate;
	private long _columnBitmask;
	private QuizCategory _escapedModelProxy;
}